package com.health.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.health.dao.CheckGroupDao;
import com.health.entity.PageResult;
import com.health.pojo.CheckGroup;
import com.health.service.CheckGroupService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * 检查组service服务实现类
 */
@Service(interfaceClass = CheckGroupService.class)
public class CheckGroupServiceImpl implements CheckGroupService {

    @Autowired
    private CheckGroupDao checkGroupDao;

    /**
     * 检查组分页查询
     * @param currentPage
     * @param pageSize
     * @param queryString
     * @return
     */
    @Override
    public PageResult pageQuery(Integer currentPage, Integer pageSize, String queryString) {
        //调用分页插件9
        PageHelper.startPage(currentPage,pageSize);
        //数据库查询分页数据
        Page<CheckGroup> page = checkGroupDao.pageQuery(queryString);
        //获取总页数
        long total = page.getTotal();
        //获取分页数据
        List<CheckGroup> rows = page.getResult();
        //返回数据
        return new PageResult(total,rows);
    }
}
